import 'package:flutter/material.dart';
import 'package:flutter_09_game/base/widget/base_get_builder.dart';
import 'package:flutter_09_game/config/app_routes.dart';
import 'package:flutter_09_game/manager/ws_manager.dart';
import 'package:flutter_09_game/user/app_user_manager.dart';
import 'package:flutter_09_game/utils/loading/loading_utils.dart';
import 'package:flutter_09_game/widgets/appbar/common_app_bar.dart';
import 'package:flutter_09_game/widgets/button/common_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'test_list_logic.dart';

class TestListPage extends StatelessWidget {
  TestListPage({Key? key}) : super(key: key);

  final TestListLogic logic = Get.put(TestListLogic());

  @override
  Widget build(BuildContext context) {
    return BaseGetBuilder<TestListLogic>(
      appBar: CommonAppBar(title: 'dasdasd'),
      // backgroundColor: Colors.red,
      builder: (l) {
        return Padding(
          padding: EdgeInsets.all(16.w),
          child: Column(
            children: [
              CommonButton(
                title: 'login',
                onClick: () {
                  Get.toNamed(AppRoutes.loginPage);
                },
              ),
              16.verticalSpaceFromWidth,
              CommonButton(
                title: '测试WebView - 百度',
                onClick: () {
                  Get.toNamed(AppRoutes.webPage, arguments: {
                    'url': 'https://www.baidu.com',
                    'title': '百度搜索',
                  });
                },
              ),
              16.verticalSpaceFromWidth,
              CommonButton(
                title: '测试WebView - GitHub',
                onClick: () {
                  Get.toNamed(AppRoutes.webPage, arguments: {
                    'url': 'https://github.com',
                  });
                },
              ),
              CommonButton(
                title: 'ws 断开连接',
                onClick: () {
                  WsManager().disconnect();
                  // Get.toNamed(AppRoutes.loginPage);
                },
              ),
              CommonButton(
                title: '退出登录',
                onClick: () {
                  // WsManager().disconnect();
                  AppUserManager().logout();
                  // Get.toNamed(AppRoutes.loginPage);
                },
              ),
              CommonButton(
                title: 'toast',
                onClick: () async {
                  LoadingUtils.showToast('caslkdfajlksd');
                  // logic.showSnackbar();
                },
              ),
              12.verticalSpaceFromWidth,
              CommonButton(
                title: 'loading',
                onClick: () async {
                  LoadingUtils.showLoading(status: 'asdfasdf');
                  Future.delayed(Duration(seconds: 2), () {
                    LoadingUtils.dismiss();
                  });
                  // logic.showSnackbar();
                },
              ),
            ],
          ),
        );
      },
    );
  }
}
